'use strict';
import * as types from '../Commom/ActionConst';
import DestinationAPIService from '../Commom/DestinationAPIService';
import RuralLibraryAPIService from '../Commom/RuralLibraryAPIService';
export let destination = (longitude, latitude,page) => {
    return (dispatch) => {
        dispatch({'type': types.kDestination});
        DestinationAPIService.destination(longitude, latitude,page).then((ret)=> {
            console.log(ret);
            dispatch({type: types.kDestinationReceived, result: ret});
        }).catch((err)=> {
            dispatch({type: types.kDestinationReceived, result: null});
        });
    }
}
export let searchDestinationMap = (city,search,longitude,latitude,scope,page) => {
    return (dispatch) => {
        dispatch({'type': types.kSearchDestinationMap});
        DestinationAPIService.searchDestinationMap(city,search,longitude,latitude,scope,page).then((ret)=> {
            console.log(ret);
            dispatch({type: types.kSearchDestinationMapReceived, result: ret});
        }).catch((err)=> {
            dispatch({type: types.kSearchDestinationMapReceived, result: null});
        });
    }
}
export let searchDestinationlist = (city,search,page) => {
    return (dispatch) => {
        dispatch({'type': types.kSearchDestinationlist});
        DestinationAPIService.searchDestinationlist(city,search,page).then((ret)=> {
            console.log(ret);
            dispatch({type: types.kSearchDestinationlistReceived, result: ret});
        }).catch((err)=> {
            dispatch({type: types.kSearchDestinationlistReceived, result: null});
        });
    }
}

export let libraryDetails = (token, registered_id, id) => {
    return (dispatch) => {
        dispatch({'type': types.CountryHomeResult});
        RuralLibraryAPIService.libraryDetails(token, registered_id, id).then((ret)=> {
            dispatch({type: types.CountryHomeResult, result: ret});
        }).catch((err)=> {
            dispatch({type: types.CountryHomeResult, result: null});
        });
    }
}